import request from "@/utils/request";
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询用户列表
export function listUser(query) {
  return request({
    url: "/system/user/list",
    method: "get",
    params: query,
  });
}

// 查询用户详细
export function getUser(userId) {
  return request({
    url: "/system/user/" + parseStrEmpty(userId),
    method: "get",
  });
}

// 新增用户
export function addUser(data) {
  return request({
    url: "/system/user",
    method: "post",
    data: data,
  });
}

// 修改用户
export function updateUser(data) {
  return request({
    url: "/system/user",
    method: "put",
    data: data,
  });
}

// 删除用户
export function delUser(userId) {
  return request({
    url: "/system/user/" + userId,
    method: "delete",
  });
}

// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password,
  };
  return request({
    url: "/system/user/resetPwd",
    method: "put",
    data: data,
  });
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status,
  };
  return request({
    url: "/system/user/changeStatus",
    method: "put",
    data: data,
  });
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: "/options/userinfo",
    method: "get",
  });
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: "/system/user/profile",
    method: "put",
    data: data,
  });
}

// 用户密码重置
export function updateUserPwd(data) {
  return request({
    url: "/person/update-password",
    method: "post",
    data,
  });
}
export function updateUserForcePwd(data) {
  return request({
    url: "/ltu/force-pwd-change",
    method: "post",
    data,
  });
}
// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: "/system/user/profile/avatar",
    method: "post",
    data: data,
  });
}

// 查询授权角色
export function getAuthRole(userId) {
  return request({
    url: "/system/user/authRole/" + userId,
    method: "get",
  });
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: "/system/user/authRole",
    method: "put",
    params: data,
  });
}

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: "/system/user/deptTree",
    method: "get",
  });
}

// 导出记录 列表
export function exportRecord(params) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: "/export_record/index",
    method: "get",
    params,
  });
}

export function exportRecordDownload(params) {
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_record/url/${params.id}`,
    method: "get",
  });
}
export function exportRecordAttr( id, data) {
  // const data = {
  //   userId,
  //   password,
  // };
  return request({
    baseURL: window.APP_GETEWAY.dexh,
    url: `/export_record/attr/${id}`,
    method: "put",
    data,
  });

}
//快捷入口列表
export function getQuickEntryList() {
  return request({
    url: "/personal-wait/fast-entrance",
    method: "get",
  });
}
//快捷入口新增
export function addQuickEntry(data) {
  return request({
    url: "/personal-wait/fast-entrance-add",
    method: "post",
    data,
  });
}
//快捷入口编辑
export function editQuickEntry(data) {
  return request({
    url: "/personal-wait/fast-entrance-update",
    method: "post",
    data,
  });
}
//快捷入口删除
export function delQuickEntry(data) {
  return request({
    url: `/personal-wait/fast-entrance-del`,
    method: "post",
    data,
  });
}
//待办事项-任务管理列表
export function getTaskList(params) {
  return request({
    url: "/personal-wait/task-management",
    method: "get",
    params,
  });
}
//待办事项-任务管理详情
export function getTaskDetail(params) {
  return request({
    url: "/personal-wait/task-management-detail",
    method: "get",
    params,
  });
}
//待办事项-任务管理新增
export function addTask(data) {
  return request({
    url: "/personal-wait/task-management-add",
    method: "post",
    data,
  });
}
//待办事项-任务管理更新
export function editTask(data) {
  return request({
    url: "/personal-wait/task-management-update",
    method: "post",
    data,
  });
}
//待办事项-任务管理状态更新
export function editTaskStatus(data) {
  return request({
    url: "/personal-wait/task-management-status-update",
    method: "post",
    data,
  });
}
//待办事项-任务管理日志
export function getTaskLog(params) {
  return request({
    url: "/personal-wait/task-management-log",
    method: "get",
    params,
  });
}

//待办数据统计-订单
export function getOmsWaitStatistic(params) {
  return request({
    baseURL: window.APP_GETEWAY.oms,
    url: "/order/wait-statistic",
    method: "get",
    params,
  });
}
//待办数据统计-商品
export function getGoodsWaitStatistic(params) {
  return request({
    baseURL: window.APP_GETEWAY.goods,
    url: "/v1/api/base/global/wait-handle",
    method: "get",
    params,
    returnData: true,
    returnError:true
  });
}
//待办数据统计-头程
export function getTcsWaitStatistic(params) {
  return request({
    baseURL: window.APP_GETEWAY.tc,
    url: "/tc_v1_pc/system/todolist",
    method: "get",
    params,
    returnData: true,
    returnError:true
  });
}
//待办数据统计-基础
export function getBaseWaitStatistic(params) {
  return request({
    baseURL: window.APP_GETEWAY.base,
    url: "/v1/shop/wait/wait-handle",
    method: "get",
    params,
    returnData: true,
    returnError:true
  });
}
